import { defineStore } from 'pinia';
import { reqC1, reqC2, reqC3 } from '@/api/attr/index';
import type { CategoryResponseData } from '@/api/attr/type';
import type { CategoryState } from './type/type';
const useCategoryStore = defineStore('category', {
    state: (): CategoryState => {
        return {
            category1: [],
            c1Id: '',
            category2: [],
            c2Id: '',
            category3: [],
            c3Id: '',
        };
    },
    actions: {
        async getCategory1() {
            const res: CategoryResponseData = await reqC1();
            if (res.code === 200) {
                this.category1 = res.data;
            }
        },
        async getCategory2() {
            const res: CategoryResponseData = await reqC2(this.c1Id);
            if (res.code === 200) {
                this.category2 = res.data;
            }
        },
        async getCategory3() {
            const res: CategoryResponseData = await reqC3(this.c2Id);
            if (res.code === 200) {
                this.category3 = res.data;
            }
        },
    },
});
export default useCategoryStore;
